package site.teamo.biu.net.server.constant;

import com.alibaba.fastjson2.JSON;
import site.teamo.biu.net.server.core.http_https_proxy.HttpHttpsProxyConfig;

import java.util.function.Supplier;

/**
 * @author haocongshun
 * @date 2023/03/07 16:56:15
 */
public enum SystemConfigEnum {

    //正向代理服务配置
    HTTP_HTTPS_PROXY("httpHttpsProxy", "Http&Https代理服务配置", true, () -> JSON.toJSONString(new HttpHttpsProxyConfig()), false);

    /**
     * 配置名称
     */
    public final String name;

    public final String zhName;

    /**
     * 不存在时，是否需要初始化
     */
    public final boolean init;

    /**
     * 是否展示标识
     */
    public final boolean show;

    /**
     * 默认值产生器
     */
    public final Supplier<String> defaultContent;


    SystemConfigEnum(String name, String zhName, boolean init, Supplier<String> defaultContent, boolean show) {
        this.name = name;
        this.zhName = zhName;
        this.init = init;
        this.defaultContent = defaultContent;
        this.show = show;
    }

    public static SystemConfigEnum valueOfName(String name) {
        for (SystemConfigEnum value : values()) {
            if (value.name.equals(name)) {
                return value;
            }
        }
        throw new IllegalArgumentException("No enum constant site.teamo.biu.net.server.constant.SystemConfigEnum.name = " + name);
    }
}
